#include<bits/stdc++.h>
using namespace std;
int n,l,r,maxn;
int main()
{
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	scanf("%d%d%d",&n,&l,&r);
	for(int i=l;i<=r;i++)
	{
		maxn=max(maxn,i%n);
		if(maxn==n-1)
			break; 
	} 
	printf("%d",maxn);
	return 0;
}
